using lucere.analysis.index;
using lucere.analysis.query;
using lucere.analysis.query.filter;
using lucere.service.search.collect;

namespace lucere.service.search
{

	/// <summary>
	/// Implements search over a single IndexReader.
	/// 
	/// <p>Applications usually need only call the inherited
	/// <see cref="ISearcher.Search(IQuery,int)"></see>
	/// or <see cref="ISearcher.Search(IQuery,IFilter,int)"></see> methods. For performance reasons it is 
	/// recommended to open only one IndexSearcher and use it for all of your searches.
	/// </p>
	/// <a name="thread-safety"></a><b>NOTE</b>: <see cref="IIndexSearcher"/>  instances are completely
	/// thread safe, meaning multiple threads can call any of its
	/// methods, concurrently.  If your application requires
	/// external synchronization, you should <b>not</b>
	/// synchronize on the <code>IIndexSearcher</code> instance;
	/// use your own (non-Lucene) objects instead.
	/// </summary>
	public interface IIndexSearcher : ISearcher
	{
		///<summary>
		/// Return the <see cref="IIndexReader"></see> this searches.
		///</summary>
		IIndexReader IndexReader { get; }

		///<summary>
		/// whether or not the fields in the returned <see cref="IFieldDoc"></see> instances should
		/// be set by specifying fillFields.
		/// <p>NOTE: this does not compute scores by default.  If you
		/// need scores, create a <see cref="ITopFieldCollector"></see>
		/// instance by calling <see cref="ITopFieldCollector.Create"></see> and
		/// then pass that to <see cref="ISearcher.Search(IWeight, IFilter, ICollector)"></see>.</p>
		///</summary>
		ITopFieldDocs Search(IWeight weight, IFilter filter, int nDocs, ISort sort, bool fillFields);

		///<summary>
		/// By default, no scores are computed when sorting by
		/// field (using <see cref="ISearcher.Search(IQuery, IFilter,int,ISort)"></see>).
		/// You can change that, per IndexSearcher instance, by
		/// calling this method.  Note that this will incur a CPU
		/// cost.
		///</summary>
		///<param name="doTrackScores">If true, then scores are returned for every matching document in {@link TopFieldDocs}.</param>
		///<param name="doMaxScore">If true, then the max score for all matching docs is computed.</param>
		void SetDefaultFieldSortScoring(bool doTrackScores, bool doMaxScore);
	}
}